diff --git a/cypress/integration/origin-save.spec.js b/cypress/integration/origin-save.spec.js
--- a/cypress/integration/origin-save.spec.js
+++ b/cypress/integration/origin-save.spec.js
@@ -215,7 +215,7 @@
assert.equal($(cells[0]).text(), requestDateStr);
assert.equal($(cells[1]).text(), this.originSaveJSON.data[i].visit_type);
let html = '';
- if (saveStatus === 'succeed') {
+ if (saveStatus === 'succeeded') {
let browseOriginUrl = `${this.Urls.browse_origin()}?origin_url=${encodeURIComponent(this.originSaveJSON.data[i].origin_url)}`;
browseOriginUrl += `×tamp=${encodeURIComponent(this.originSaveJSON.data[i].visit_date)}`;
html += `${this.originSaveJSON.data[i].origin_url}`;
@@ -237,7 +237,7 @@
const saveRequestData = genOriginSaveResponse({
saveRequestStatus: 'accepted',
originUrl: originUrl,
- saveTaskStatus: 'succeed',
+ saveTaskStatus: 'succeeded',
visitDate: null
});
const saveRequestsListData = {
diff --git a/swh/web/api/views/origin_save.py b/swh/web/api/views/origin_save.py
--- a/swh/web/api/views/origin_save.py
+++ b/swh/web/api/views/origin_save.py
@@ -49,7 +49,7 @@
* **not yet scheduled**: saving task has been created but its
execution has not yet been scheduled
* **scheduled**: the task execution has been scheduled
- * **succeed**: the saving task has been successfully executed
+ * **succeeded**: the saving task has been successfully executed
* **failed**: the saving task has been executed but it failed
When issuing a POST request an object will be returned while a GET
@@ -70,7 +70,7 @@
either **accepted**, **rejected** or **pending**
:>json string save_task_status: the status of the origin saving task,
either **not created**, **not yet scheduled**, **scheduled**,
- **succeed** or **failed**
+ **succeeded** or **failed**
:statuscode 200: no error
:statuscode 400: an invalid visit type or origin url has been provided
diff --git a/swh/web/assets/src/bundles/save/index.js b/swh/web/assets/src/bundles/save/index.js
--- a/swh/web/assets/src/bundles/save/index.js
+++ b/swh/web/assets/src/bundles/save/index.js
@@ -88,7 +88,7 @@
if (type === 'display') {
let html = '';
const sanitizedURL = $.fn.dataTable.render.text().display(data);
- if (row.save_task_status === 'succeed') {
+ if (row.save_task_status === 'succeeded') {
let browseOriginUrl = `${Urls.browse_origin()}?origin_url=${encodeURIComponent(sanitizedURL)}`;
if (row.visit_date) {
browseOriginUrl += `×tamp=${encodeURIComponent(row.visit_date)}`;
@@ -114,7 +114,7 @@
{
name: 'info',
render: (data, type, row) => {
- if (row.save_task_status === 'succeed' || row.save_task_status === 'failed') {
+ if (row.save_task_status === 'succeeded' || row.save_task_status === 'failed') {
return ``;
diff --git a/swh/web/common/migrations/0007_save_request_task_status_fix_typo.py b/swh/web/common/migrations/0007_save_request_task_status_fix_typo.py
new file mode 100644
--- /dev/null
+++ b/swh/web/common/migrations/0007_save_request_task_status_fix_typo.py
@@ -0,0 +1,43 @@
+# Copyright (C) 2020 The Software Heritage developers
+# See the AUTHORS file at the top-level directory of this distribution
+# License: GNU Affero General Public License version 3, or any later version
+# See top-level LICENSE file for more information
+
+from django.db import migrations, models
+
+
+def _rename_request_status_from_succeed_to_succeeded(apps, schema_editor):
+ """
+ Fix a typo in save request status value.
+ """
+ SaveOriginRequest = apps.get_model("swh.web.common", "SaveOriginRequest")
+ for sor in SaveOriginRequest.objects.all():
+ if sor.loading_task_status == "succeed":
+ sor.loading_task_status = "succeeded"
+ sor.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("swh.web.common", "0006_rename_origin_type"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="saveoriginrequest",
+ name="loading_task_status",
+ field=models.TextField(
+ choices=[
+ ("not created", "not created"),
+ ("not yet scheduled", "not yet scheduled"),
+ ("scheduled", "scheduled"),
+ ("succeeded", "succeeded"),
+ ("failed", "failed"),
+ ("running", "running"),
+ ],
+ default="not created",
+ ),
+ ),
+ migrations.RunPython(_rename_request_status_from_succeed_to_succeeded),
+ ]
diff --git a/swh/web/common/models.py b/swh/web/common/models.py
--- a/swh/web/common/models.py
+++ b/swh/web/common/models.py
@@ -50,7 +50,7 @@
SAVE_TASK_NOT_CREATED = "not created"
SAVE_TASK_NOT_YET_SCHEDULED = "not yet scheduled"
SAVE_TASK_SCHEDULED = "scheduled"
-SAVE_TASK_SUCCEED = "succeed"
+SAVE_TASK_SUCCEEDED = "succeeded"
SAVE_TASK_FAILED = "failed"
SAVE_TASK_RUNNING = "running"
@@ -58,7 +58,7 @@
(SAVE_TASK_NOT_CREATED, SAVE_TASK_NOT_CREATED),
(SAVE_TASK_NOT_YET_SCHEDULED, SAVE_TASK_NOT_YET_SCHEDULED),
(SAVE_TASK_SCHEDULED, SAVE_TASK_SCHEDULED),
- (SAVE_TASK_SUCCEED, SAVE_TASK_SUCCEED),
+ (SAVE_TASK_SUCCEEDED, SAVE_TASK_SUCCEEDED),
(SAVE_TASK_FAILED, SAVE_TASK_FAILED),
(SAVE_TASK_RUNNING, SAVE_TASK_RUNNING),
]
diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py
--- a/swh/web/common/origin_save.py
+++ b/swh/web/common/origin_save.py
@@ -31,7 +31,7 @@
SAVE_TASK_NOT_YET_SCHEDULED,
SAVE_TASK_RUNNING,
SAVE_TASK_SCHEDULED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
SaveAuthorizedOrigin,
SaveOriginRequest,
SaveUnauthorizedOrigin,
@@ -106,7 +106,7 @@
_save_task_status = {
"next_run_not_scheduled": SAVE_TASK_NOT_YET_SCHEDULED,
"next_run_scheduled": SAVE_TASK_SCHEDULED,
- "completed": SAVE_TASK_SUCCEED,
+ "completed": SAVE_TASK_SUCCEEDED,
"disabled": SAVE_TASK_FAILED,
}
@@ -173,7 +173,7 @@
save_request.visit_date = visit_date
# visit has been performed, mark the saving task as succeed
if visit_date and visit_status is not None:
- save_task_status = SAVE_TASK_SUCCEED
+ save_task_status = SAVE_TASK_SUCCEEDED
elif visit_status == "ongoing":
save_task_status = SAVE_TASK_RUNNING
else:
@@ -195,8 +195,11 @@
# Consider request from which a visit date has already been found
# as succeeded to avoid retrieving it again
if save_task_status == SAVE_TASK_SCHEDULED and visit_date:
- save_task_status = SAVE_TASK_SUCCEED
- if save_task_status in (SAVE_TASK_FAILED, SAVE_TASK_SUCCEED) and not visit_date:
+ save_task_status = SAVE_TASK_SUCCEEDED
+ if (
+ save_task_status in (SAVE_TASK_FAILED, SAVE_TASK_SUCCEEDED)
+ and not visit_date
+ ):
visit_date, _ = _get_visit_info_for_save_request(save_request)
save_request.visit_date = visit_date
must_save = True
@@ -313,7 +316,10 @@
task_status = _save_request_dict(sor, task)["save_task_status"]
# create a new scheduler task only if the previous one has been
# already executed
- if task_status == SAVE_TASK_FAILED or task_status == SAVE_TASK_SUCCEED:
+ if (
+ task_status == SAVE_TASK_FAILED
+ or task_status == SAVE_TASK_SUCCEEDED
+ ):
can_create_task = True
sor = None
else:
@@ -589,7 +595,7 @@
SAVE_TASK_NOT_CREATED,
SAVE_TASK_NOT_YET_SCHEDULED,
SAVE_TASK_SCHEDULED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
SAVE_TASK_FAILED,
SAVE_TASK_RUNNING,
)
diff --git a/swh/web/tests/api/views/test_origin_save.py b/swh/web/tests/api/views/test_origin_save.py
--- a/swh/web/tests/api/views/test_origin_save.py
+++ b/swh/web/tests/api/views/test_origin_save.py
@@ -17,7 +17,7 @@
SAVE_TASK_NOT_CREATED,
SAVE_TASK_NOT_YET_SCHEDULED,
SAVE_TASK_SCHEDULED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
SaveOriginRequest,
SaveUnauthorizedOrigin,
)
@@ -195,7 +195,7 @@
mocker,
origin_url,
SAVE_REQUEST_ACCEPTED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
scheduler_task_status="completed",
visit_date=None,
)
@@ -205,7 +205,7 @@
mocker,
origin_url,
SAVE_REQUEST_ACCEPTED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
scheduler_task_status="completed",
visit_date=visit_date,
)
diff --git a/swh/web/tests/common/test_origin_save.py b/swh/web/tests/common/test_origin_save.py
--- a/swh/web/tests/common/test_origin_save.py
+++ b/swh/web/tests/common/test_origin_save.py
@@ -29,9 +29,7 @@
@pytest.fixture(autouse=True)
def requests_mock_datadir(datadir, requests_mock_datadir):
- """Override default behavior to deal with post method
-
- """
+ """Override default behavior to deal with post method"""
cb = partial(get_response_cb, datadir=datadir)
requests_mock_datadir.post(re.compile("https?://"), body=cb)
return requests_mock_datadir
@@ -57,7 +55,7 @@
_get_save_origin_task_info_test(mocker, es_available=False)
-def _mock_scheduler(mocker, task_status="succeed", task_archived=False):
+def _mock_scheduler(mocker, task_status="succeeded", task_archived=False):
mock_scheduler = mocker.patch("swh.web.common.origin_save.scheduler")
task = (
{
diff --git a/swh/web/tests/misc/test_metrics.py b/swh/web/tests/misc/test_metrics.py
--- a/swh/web/tests/misc/test_metrics.py
+++ b/swh/web/tests/misc/test_metrics.py
@@ -18,7 +18,7 @@
SAVE_TASK_NOT_YET_SCHEDULED,
SAVE_TASK_RUNNING,
SAVE_TASK_SCHEDULED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
SaveOriginRequest,
)
from swh.web.common.origin_save import (
@@ -43,7 +43,7 @@
SAVE_TASK_NOT_CREATED,
SAVE_TASK_NOT_YET_SCHEDULED,
SAVE_TASK_SCHEDULED,
- SAVE_TASK_SUCCEED,
+ SAVE_TASK_SUCCEEDED,
SAVE_TASK_FAILED,
SAVE_TASK_RUNNING,
)